package de.akad.imp03.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

import de.akad.imp03.client.UITexte;

public class WelcomePage {

	public Widget onInitialize() {
		UITexte uitexte = (UITexte)GWT.create(UITexte.class);
		final VerticalPanel centerPanel = new VerticalPanel();
		final HTML text = new HTML (uitexte.welcome());
		final PushButton bnLos = new PushButton(new Image("/img/bn_losgehts.png"));

		bnLos.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				ControlCenter cc = new ControlCenter();
				RootPanel.get("mainPanel").clear();
				RootPanel.get("mainPanel").add(cc.onInitialize());
			}
		});
		
		final HorizontalPanel buttonPanel = new HorizontalPanel();
		buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		
		text.addStyleName("title");
		buttonPanel.add(bnLos);
		centerPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
		centerPanel.add(text);
		
		final DockPanel main = new DockPanel();
		main.setWidth("80%");
		main.setHeight("100%");
		main.add(centerPanel, DockPanel.CENTER);
		main.setCellVerticalAlignment(centerPanel, HasVerticalAlignment.ALIGN_MIDDLE);
		main.add(buttonPanel, DockPanel.SOUTH);
		main.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);
		
		return main;
	}
}
